﻿using System;
using JetBrains.Annotations;
using MugenMvvmToolkit.Annotations;
using MugenMvvmToolkit.Interfaces.Views;

namespace MugenMvvmToolkit.Attributes
{
    /// <summary>
    ///     Represents the attribute to bind view to view model, not use it for page.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
    [BaseTypeRequired(typeof(IView))]
    public sealed class ViewModelAttribute : Attribute
    {
        #region Constructor

        /// <summary>
        ///     Initializes a new instance of the <see cref="ViewModelAttribute" /> class.
        /// </summary>
        /// <param name="viewModelType">The specified type of view model.</param>
        public ViewModelAttribute([NotNull, ViewModelTypeRequired]Type viewModelType)
        {
            Should.NotBeNull(viewModelType, "viewModelType");
            Should.BeViewModel(viewModelType, "viewModelType");
            ViewModelType = viewModelType;
        }

        #endregion

        #region Properties

        /// <summary>
        ///     Gets the type of view model.
        /// </summary>
        public Type ViewModelType { get; private set; }

        /// <summary>
        ///     Gets or sets the name of view binding.
        /// </summary>
        public string Name { get; set; }

        #endregion
    }
}